<template>
  <div>
    <div class="maincss operlog">
      <el-row>
        <el-card>
<!--          <searchBox title='操作日志' :btn='btn' @func='showBtn'/>-->
          <el-row class="searchbox">
            <el-col span="1"> 操作日志</el-col>
            <el-col span="3">
              <el-input
                placeholder="仪器名称"
                v-model="queryParams.instrumentName"
              >
              </el-input>
            </el-col>
            <el-col span="3">
              <el-input
                placeholder="仪器编号"
                v-model="queryParams.instrumentNo"
              >
              </el-input>
            </el-col>
            <el-col span="1">
              <el-button @click="handleLoadAndQuery" type="primary">查询</el-button>
            </el-col>
            <el-col span="2">
              <el-button @click="handleExport" type="primary">导出</el-button>
            </el-col>
          </el-row>
          <el-card class="gray-card no-border no-margin-top" shadow="never">
            <el-table
              v-loading="loading"
              :data="checkList"
              style="width: 100%;"
            >
              <el-table-column label="仪器编号" align="center" prop="instrumentNo" :show-overflow-tooltip="true"/>
              <el-table-column label="仪器名称" align="center" prop="instrumentName"/>
              <el-table-column label="操作类型" align="center" prop="optType" :show-overflow-tooltip="true"/>
              <el-table-column label="操作人" align="center" prop="operator" :show-overflow-tooltip="true"/>
              <el-table-column label="操作时间" align="center" prop="optTime"/>
              <el-table-column label="所属科室" align="center" prop="deptName"/>

            </el-table>
          </el-card>
          <pagination v-show="total>0" :total="total"
                      :page.sync="queryParams.pageNum"
                      :limit.sync="queryParams.pageSize"
                      @pagination="handleLoadAndQuery"/>
        </el-card>
      </el-row>
    </div>
  </div>
</template>

<script>
import {listInstrumentLogs} from "@/api/business/instrumentLogs"
import { downLoadExcel } from "@/utils/download";

export default {
  name: "operlog",
  components: {},
  data() {
    return {
      btn: {
        add: false,
        reg: false,
        down: false,
        export: true,
        imp: false,
        search: true
      },
      total: 10,
      checkList: [],
      loading: false,
      redirect: undefined,
      activeName: '1',
      deviceInfo: {},
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        instrumentNo: '',
        instrumentName: ''
      }
    };
  },
  watch: {},
  created() {
    this.handleLoadAndQuery()
  },
  methods: {
    showBtn(data) {
      if (data == 'search') {
        this.handleLoadAndQuery()
      } else if (data == 'export') {
        this.handleExport()
      }
    },
    handleLoadAndQuery() {
      this.loading = true;
      listInstrumentLogs(this.queryParams).then((res) => {
        this.loading = false;
        this.total = res.total;
        this.checkList = res.rows;
      })
    },
    handleExport() {
      downLoadExcel('/system/instrumentLogs/export', this.queryParams);
    }
  }
};
</script>
